import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// 配置路由表
const routes = [
  {
    path: '/login',
    // 设置路由的名称，命名路由。
    name: 'login',
    component: () => import('@/views/login')
  },
  {
    path: '/',
    // 设置路由的名称，命名路由。
    name: 'layout',
    component: () => import('@/views/layout/layout.vue'),
    children: [
      {
        path: '',
        name: 'shouye',
        component: () => import('@/views/layoutC/shouye')
      }, {
        path: 'shipin',
        name: 'shipin',
        component: () => import('@/views/layoutC/shipin')
      }, {
        path: 'wenda',
        name: 'wenda',
        component: () => import('@/views/layoutC/wenda')
      }, {
        path: 'wode',
        name: 'wode',
        component: () => import('@/views/layoutC/wode')
      }
    ]
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/search')
  },
  {
    path: '/article/:articleId',
    name: 'article',
    component: () => import('@/views/article'),
    props: true
  },
  {
    path: '/user/:userId',
    name: 'user',
    component: () => import('@/views/user')
  }
]

const router = new VueRouter({
  mode: 'history',
  routes
})

export default router
